<?php

use yii\db\Migration;

/**
 * Class m200628_030438_user_equ
 */
class m200628_030438_user_equ extends Migration
{
    public function up()
    {
        $tableOptions = null;
        if ($this->db->driverName === 'mysql') {
            // http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
            $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
        }

        $this->createTable('{{%user_equ}}', [
            'id'               => $this->integer(),
            'user_id'          =>  $this->integer()->notNull(),
            'type'             => $this->tinyInteger()->notNull()->defaultValue(1),
            'equ_id'           =>  $this->integer()->notNull(),
            'created_at'       => $this->integer()->notNull(),
            'updated_at'       => $this->integer()->notNull(),
            'PRIMARY KEY ([[id]])',
        ], $tableOptions);
    }

    public function down()
    {
        $this->dropTable('{{%user_equ}}');
        return false;
    }


    /* public function safeUp()
     {

     }

     public function safeDown()
     {
         echo "m200619_101629_user cannot be reverted.\n";

         return false;
     }*/
}
